package com.java.al.reflex;

import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.sql.ResultSet;

public class Reflex {
	public static void main(String[] args) {
		try {
			Object obj = Class.forName("reflex.TestClass").newInstance();
			Field[] fd = obj.getClass().getFields();
			Field[] allFd = obj.getClass().getDeclaredFields();
			for (int i = 0; i < allFd.length; i++) {
				System.out.println(allFd[i].getName());
			}
			Method[] md = obj.getClass().getMethods();
			for (int i = 0; i < md.length; i++) {
//				System.out.println(md[i].getName());
			}
			
			Method mo = obj.getClass().getMethod("outMethod", new Class[]{String.class,int.class });
			String str = (String) mo.invoke(obj, "这就是输出",1 );
			System.out.println( str );
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (SecurityException e) {
			e.printStackTrace();
		} 
		catch (NoSuchMethodException e) {
			e.printStackTrace();
		} catch (IllegalArgumentException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} catch (InvocationTargetException e) {
			e.printStackTrace();
		} catch (InstantiationException e) {
			e.printStackTrace();
		}
	}
}
